//
//  AppDelegate+QYShareSDK.m
//  QYBaseProject
//
//  Created by Dxc_iOS on 2018/7/20.
//  Copyright © 2018年 代星创. All rights reserved.
//

#import "AppDelegate+QYShareSDK.h"
#import "Configuration.h"

#define Wechat_key    @"wxca16b769e56e7fb5"

#define Wechat_Secret @"c57b3ffaa9013f0fc204feaf2a3d4161"

#define QQ_key        @"1106484558"

#define QQ_Secret     @"iKT7h67ciKUFknH4"

#define Weibo_key     @"2273922718"

#define Weibo_Secret  @"e7bac93280ae624ff0e777b1551d18b5"

@interface AppDelegate()<WXApiDelegate>

@end

@implementation AppDelegate (QYShareSDK)
- (void)initShareSDK_application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    
    [WXApi registerApp:Wechat_key];
    //
    [ShareSDK registerActivePlatforms:@[
                                        @(SSDKPlatformTypeSinaWeibo),
                                        @(SSDKPlatformTypeWechat),
                                        @(SSDKPlatformTypeQQ),
                                        ]
                             onImport:^(SSDKPlatformType platformType)
     {
         switch (platformType)
         {
             case SSDKPlatformTypeWechat:
                 [ShareSDKConnector connectWeChat:[WXApi class]];
                 break;
             case SSDKPlatformTypeQQ:
                 [ShareSDKConnector connectQQ:[QQApiInterface class] tencentOAuthClass:[TencentOAuth class]];
                 break;
             case SSDKPlatformTypeSinaWeibo:
                 [ShareSDKConnector connectWeibo:[WeiboSDK class]];
                 break;
             default:
                 break;
         }
     }
                      onConfiguration:^(SSDKPlatformType platformType, NSMutableDictionary *appInfo)
     {
         
         switch (platformType)
         {
             case SSDKPlatformTypeSinaWeibo:
                 //设置新浪微博应用信息,其中authType设置为使用SSO＋Web形式授权
                 [appInfo SSDKSetupSinaWeiboByAppKey:Weibo_key
                                           appSecret:Weibo_Secret
                                         redirectUri:@"http://www.sharesdk.cn"
                                            authType:SSDKAuthTypeBoth];
                 break;
             case SSDKPlatformTypeWechat:
                 [appInfo SSDKSetupWeChatByAppId:Wechat_key
                                       appSecret:Wechat_Secret];
                 break;
             case SSDKPlatformTypeQQ:
                 [appInfo SSDKSetupQQByAppId:QQ_key
                                      appKey:QQ_Secret
                                    authType:SSDKAuthTypeBoth];
                 break;
                 
             default:
                 break;
         }
     }];
    //
}
-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    return [WXApi handleOpenURL:url delegate:self];
}
@end
